/*
 * 
 */

#include <iostream>
#include <math.h>
#include <stack>

using namespace std;

void merge(int grades[][2], int p, int q, int r)
{
	int **temp = new int*[r - p + 1];
	for (int i = 0; i < r - p + 1; i++) {
		temp[i] = new int[2];
	}

	int s = p, t = q + 1, k = 0;
	while (s <= q && t <= r) {
		if ((grades[s][0] - grades[s][1]) < (grades[t][0] - grades[t][1])) {
			temp[k][0] = grades[s][0];
			temp[k][1] = grades[s][1];

			++s;
		} else if ((grades[s][0] - grades[s][1]) > (grades[t][0] - grades[t][1])) {
			temp[k][0] = grades[t][0];
			temp[k][1] = grades[t][1];

			++t;
		} else if ((grades[s][0] + grades[s][1]) < (grades[t][0] + grades[t][1])) {
			temp[k][0] = grades[s][0];
			temp[k][1] = grades[s][1];

			++s;
		} else {
			temp[k][0] = grades[t][0];
			temp[k][1] = grades[t][1];

			++t;
		}
		++k;
	}

	if (s > q) {
		while (t <= r) {
			temp[k][0] = grades[t][0];
			temp[k][1] = grades[t][1];

			++t;
			++k;
		}
	}

	if (t > r) {
		while (s <= q) {
			temp[k][0] = grades[s][0];
			temp[k][1] = grades[s][1];

			++s;
			++k;
		}
	}

	for (int i = 0; i < k; i++) {
		grades[p + i][0] = temp[i][0];
		grades[p + i][1] = temp[i][1];
	}

	for (int i = 0; i < r - p + 1; i++) {
		delete[] temp[i];
	}
	delete[] temp;
}

void mergeSort(int grades[][2], int low, int high)
{
	int size = high - low + 1;
	int subSize = 1;
	while (subSize < size) {
		int p = 0;
		int q = p + subSize - 1;
		int r = (q + subSize) > high ? high : q + subSize;
		while (q < high) {
			merge(grades, p, q, r);
			p = r + 1;
			q = p + subSize - 1;
			r = (q + subSize) > high ? high : q + subSize;
		}
		subSize *= 2;
	}
}

int split(int grades[][2], int* indices, int low, int high)
{
	int swapIndex = low + 1;
	int i = low + 1;
	int temp;
	for (; i <= high; i++) {
		if ((grades[i][0] - grades[i][1]) < (grades[low][0] - grades[low][1]) 
			|| ((grades[i][0] - grades[i][1]) == (grades[low][0] - grades[low][1]) && (grades[i][0] + grades[i][1]) < (grades[low][0] + grades[low][1]))) {
			temp = grades[i][0];
			grades[i][0] = grades[swapIndex][0];
			grades[swapIndex][0] = temp;

			temp = grades[i][1];
			grades[i][1] = grades[swapIndex][1];
			grades[swapIndex][1] = temp;

			temp = indices[swapIndex];
			indices[swapIndex] = indices[i];
			indices[i] = temp;

			++swapIndex;
		}
	}

	--swapIndex;

	temp = grades[swapIndex][0];
	grades[swapIndex][0] = grades[low][0];
	grades[low][0] = temp;

	temp = grades[swapIndex][1];
	grades[swapIndex][1] = grades[low][1];
	grades[low][1] = temp;

	temp = indices[swapIndex];
	indices[swapIndex] = indices[low];
	indices[low] = temp;

	return swapIndex;
}

void quickSort(int grades[][2], int *indices, int low, int high)
{
	typedef pair<int, int> Int_Pair;
	stack<Int_Pair> pairs;
	pairs.push(Int_Pair(low, high));
	while (!pairs.empty())
	{
		Int_Pair pair = pairs.top();
		pairs.pop();
		int flag = split(grades, indices, pair.first, pair.second);
		if (pair.first < flag - 1)
			pairs.push(Int_Pair(pair.first, flag - 1));

		if (pair.second > flag + 1) 
			pairs.push(Int_Pair(flag + 1, pair.second));
	}
}

int main(int argc, char* argv[])
{
	const int MAXNUMBER = 200;
	//int candidates[MAXNUMBER];
	//int jurors[MAXNUMBER];
	int grades[MAXNUMBER][2], backup[MAXNUMBER][2];
	int indices[MAXNUMBER];
	bool isSelected[MAXNUMBER];
	int n, m;
	scanf("%d %d", &n, &m);
	int juryNum = 1;
	while (n != 0 && m != 0) {
		int di, pi;
		for (int i = 0; i < n; i++) {
			scanf("%d %d", &di, &pi);
			grades[i][0] = backup[i][0] = di;
			grades[i][1] = backup[i][1] = pi;			
			indices[i] = i;
		}

		//mergeSort(grades, 0, n - 1);
		quickSort(grades, indices, 0, n - 1);

		int firstIndex = -1/*, secondIndex = -1*/;
		//bool isFindFirst = true;
		for (int i = 0; i < n; i++) {
			if ((grades[i][0] - grades[i][1]) >= 0 /*&& isFindFirst*/) {
				firstIndex = i;
				/*isFindFirst = false;
				--i;*/
				break;
			} /*else if ((grades[i][0] - grades[i][1]) > 0) {
				secondIndex = i;
			}*/
		}
		if (firstIndex == -1)
			firstIndex = n;
		int minAbsDiffSum = 4000;
		int maxAbsAddSum = -1;
		int prosecution = 0, diffSum;
		int defence = 0, addSum;
		int selectedIndex = firstIndex;
		while (true) {
			if (firstIndex >= m) {
				if (grades[firstIndex - m][0] > grades[firstIndex - m][1])
					break;
				prosecution = 0;
				defence = 0;
				for (int j = firstIndex - m; j < firstIndex; j++) {
					prosecution += grades[j][0];
					defence += grades[j][1];
				}
				diffSum = abs(prosecution - defence);
				addSum = prosecution + defence;
				if (diffSum < minAbsDiffSum) {
					minAbsDiffSum = diffSum;
					maxAbsAddSum = addSum;
					selectedIndex = firstIndex;
				} else if (diffSum == minAbsDiffSum) {
					if (addSum > maxAbsAddSum) {
						maxAbsAddSum = addSum;
						selectedIndex = firstIndex;
					}
				}
			}
			++firstIndex;
		}

		/*int numberOfZeros = secondIndex - firstIndex;*/

		/*int sum = 0;
		int pre = sum;
		for (int i = 0; i < n; i++) {
			pre = sum;
			sum += (grades[i][0] - grades[i][1]);
		}*/
		cout<<"Jury #"<<juryNum<<endl;
		++juryNum;
		cout<<"Best jury has value "<<prosecution<<" for prosecution and value "<<defence<<" for defence:"<<endl;
		--firstIndex;
		memset(isSelected, false, sizeof(bool) * MAXNUMBER);
		for (int j = firstIndex - m; j < firstIndex; j++) {
			//for (int k = 0; k < n; k++) {
			//	if (grades[j][0] == backup[k][0] && grades[j][1] == backup[k][1])
			//		//cout<<" "<<k + 1;
			//		isSelected[k] = true;
			//}
			isSelected[indices[j]] = true;
		}

		for (int k = 0; k < n; k++) {
			if (isSelected[k])
				cout<<" "<<k + 1;
		}
		cout<<endl<<endl;

		scanf("%d %d", &n, &m);
	}
	return 0;
}
